layui.define(["table", "form", "admin", "upload"], function (exports) {
    var $ = layui.$,
        table = layui.table;

    table.render({
        elem: "#LAY-chat-manage",
        url: config.report_get_chat,
        cols: [
            [
                { field: "uid", width: 100, title: "主播ID" },
                {
                    field: "nick_name",
                    width: 100,
                    title: "主播昵称",
                },
                { field: "live_id", minWidth: 100, title: "直播间编号" },
                { field: "title", minWidth: 100, title: "直播间标题" },
                {
                    field: "category_text",
                    minWidth: 150,
                    title: "直播类别",
                    // templet: function (d) {
                    //     if (d.category == 1) {
                    //         return "娱乐";
                    //     } else {
                    //         return "体育";
                    //     }
                    // },
                },
                { field: "hot", minWidth: 100, title: "热度值" },
                {
                    field: "new_fans_count",
                    minWidth: 100,
                    title: "新增粉丝数",
                },
                {
                    field: "",
                    minWidth: 100,
                    title: "总粉丝数",
                    templet: function (d) {
                        return d.fans_count ?? 0;
                    },
                },
                {
                    field: "message_count",
                    minWidth: 100,
                    title: "新增消息数",
                },
                {
                    field: "",
                    minWidth: 100,
                    title: "直播状态",
                    templet: function (d) {
                        return d.status == 1
                            ? '<span class="layui-badge layui-bg-green">直播中</span>'
                            : '<span class="layui-badge layui-bg-red">已结束</span>';
                    },
                },
                {
                    field: "viewer_count",
                    minWidth: 100,
                    title: "观看人次",
                },
                {
                    field: "online_peak",
                    minWidth: 100,
                    title: "人数峰值",
                },
                {
                    field: "",
                    minWidth: 150,
                    title: "礼物总数/宝石",
                    templet: function (d) {
                        return d.gift_num + "/" + d.gift_total_value;
                    },
                },
                {
                    field: "",
                    minWidth: 150,
                    title: "钻石总数/钻石",
                    templet: function (d) {
                        return d.gift_diamond_total_num + "/" + d.gift_diamond_total_price;
                    },
                },
                {
                    field: "anthor_total_income",
                    minWidth: 100,
                    title: "主播收益",
                },
            ],
        ],
        page: true,
        limit: 20,
        height: "full-140",
        text: "对不起，加载出现异常！",
        even: true,
    });

    table.render({
        elem: "#LAY-chat-summary",
        url: config.report_get_summary,
        cols: [
            [
                {
                    field: "",
                    width: 100,
                    title: '<span class="layui-badge">新增粉丝</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.new_fans +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    width: 100,
                    title: '<span class="layui-badge">直播场次</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.live_count +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">新增消息</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.message_count +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">观看人次</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.viewer_count +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">人数峰值</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.online_peak +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">热度值</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' + d.hot + "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">礼物数/总价值</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' + d.gift_num + "/" + d.gift_total_value + "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">主播收益</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' + d.anchor_income + "</span>"
                        );
                    },
                },
            ],
        ],
        text: "对不起，加载出现异常！",
        even: true,
    });

    table.render({
        elem: "#LAY-anchor-manage",
        url: config.report_get_anchor,
        cols: [
            [
                { field: "nick_name", width: 120, title: "主播名称" },
                { field: "anchorid", title: "房间ID", width: 140 },
                { field: "times", title: "总直播场次", width: 100 },
                { field: "duration", title: "直播总时长(分钟)", width: 150 },
                { field: "avg_duration", title: "平均直播时长", width: 120 },
                {
                    field: "",
                    width: 90,
                    title: "分成比例",
                    templet: function (d) {
                        return d.sharing_ratio + "%";
                    },
                },
                { field: "gift_num_people", width: 100, title: "送礼总人数" },
                { field: "avg_gift_num_people", width: 120, title: "平均送礼人数" },
                { field: "gift_profit", width: 100, title: "送礼总价值" },
                { field: "avg_gift_profit", width: 120, title: "平均送礼价值" },
                { field: "anchor_income", width: 120, title: "主播总收益" },
                { field: "avg_anchor_income", width: 120, title: "平均主播收益" },
                { field: "barrage_time_count", width: 120, title: "总弹幕数量" },
                {
                    field: "avg_barrage_time_count",
                    width: 120,
                    title: "平均弹幕数量",
                },
                { field: "avg_new_fans_count", width: 120, title: "平均新增粉丝" },
                { field: "fans_count", width: 100, title: "总粉丝数" },
            ],
        ],
        page: true,
        limit: 20,
        height: "full-140",
        text: "对不起，加载出现异常！",
        even: true,
    });


    // 经纪人报表
    table.render({
        elem: '#LAY-guild-manager'
        , url: config.report_get_manager_list
        , cols: [[
            { field: 'id', width: 100, title: 'ID', sort: true }
            , { field: 'mobile', minWidth: 200, title: '账号' }
            , { field: 'real_name', width: 200, title: '真实姓名' }
            , {
                field: '', width: 120, title: '角色', templet: function (d) {
                    return d.role ? d.role.name : '';
                }
            }
            , {
                field: '', width: 200, title: '直属上级', templet: function (d) {
                    return d.parent ? d.parent.real_name : '';
                }
            }
            , { field: 'diamond', width: 120, title: '总宝石' }
            , { field: 'anchor_count', width: 120, title: '管理主播总数' }
            , { field: 'on_live_count', width: 120, title: '正在直播人数' }
            , { field: 'open_live_count', width: 120, title: '开播人数' }
        ]]
        , page: true
        , limit: 20
        , height: 'full-180'
        , text: '对不起，加载出现异常！'
        , even: true
    });

    // 注册用户报表
    table.render({
        elem: '#LAY-user-manage'
        , url: config.report_user_handle
        , cols: [[
            { field: 'id', width: 100, title: 'ID', }
            , { field: 'mobile', width: 200, title: '账号' }
            , { field: 'nick_name', width: 200, title: '昵称' },
            {
                field: "",
                width: 100,
                title: "注册设备",
                templet: function (d) {
                    if (d.regist_type == 1) {
                        return 'WEB';
                    }
                    if (d.regist_type == 2) {
                        return 'IOS';
                    }
                    if (d.regist_type == 3) {
                        return 'ANDROID';
                    }
                    if (d.regist_type == 4) {
                        return 'H5';
                    }
                },
            },
            {
                field: "",
                title: "头像",
                width: 80,
                templet: function (d) {
                    if (d.avatar) {
                        return (
                            '<img style="display: block;margin:0px auto; height: 100%;" src= "' +
                            d.avatar +
                            '">'
                        );
                    } else {
                        return "无";
                    }
                },
            },
            {
                field: "",
                title: "帐号状态",
                width: 100,
                templet: function (d) {
                    if (d.status == 0) {
                        return '<span class="layui-badge layui-bg-green">正常</span>';
                    }
                    if (d.status == 1) {
                        return '<span class="layui-badge layui-bg-danger">封禁</span>';
                    }
                    if (d.status == 2) {
                        return '<span class="layui-badge layui-bg-warning">暂时冻结</span>';
                    }
                    if (d.status == 3) {
                        return '<span class="layui-badge layui-bg-warning">被踢出</span>';
                    }
                    if (d.status == 4) {
                        return '<span class="layui-badge layui-bg-warning">销户</span>';
                    }
                },
            },
            {
                field: "",
                title: "是否贵族",
                width: 95,
                align: "center",
                templet: function (d) {
                    if (d.noble && d.noble.length > 0) {
                        return "是";
                    }

                    return "否";
                },
            },
            { field: "last_login", title: "最后一次登录时间", width: 180 },
            , { field: 'regist_time', width: 200, title: '注册时间' }
        ]]
        , page: true
        , limit: 20
        , height: 'full-180'
        , text: '对不起，加载出现异常！'
        , even: true
    });


    exports("guild/report", {});
});
